/**
 * @file   random.hpp
 * @author Kimmo Luoma <kimmo@PHOTON3>
 * @date   Fri Sep  7 11:51:17 2012
 * 
 * @brief  Random numbers class
 * 
 * 
 */
#ifndef RANDOM_HPP
#define RANDOM_HPP
#include<gsl/gsl_rng.h>
#include<gsl/gsl_randist.h>
#include<boost/numeric/ublas/vector.hpp>
#include<ctime>
using namespace boost::numeric::ublas;
/**
 *Class MyRandom for generating random numbers.
 *This class uses random number generator from
 *GNU Scientific library
 */

class MyRandom{
private:
  /// Pointer to gsl_random number generator
  gsl_rng *r;
public:
  /** 
   * Constructor
   * 
   * @param t pointer to gsl_rng_type. default gsl_rng_ranlxs2 
   */
  MyRandom(const gsl_rng_type *t=gsl_rng_ranlxs2);
  /** 
   * Copy constructor
   * 
   * @param rng 
   */
  MyRandom(const MyRandom& rng);
  
  /** 
   * Copy assingment
   * 
   * @param rng 
   * 
   * @return 
   */
  MyRandom& operator=(const MyRandom& rng);
  
  /** 
   * Destructor
   * 
   */
  ~MyRandom();
  /** 
   * Seed the rng using std::time(0)
   * 
   */
  void set();
  /** 
   * 
   * Sample one sample from rng.
   * 
   * @return double prec. floating point number uniformly distributed in [0,1)
   *
   */
  double sample();
  /** 
   * Sample from discrete distribution
   * 
   * @param p vector<double> discrete distribution
   * 
   * @return sample from discrete distribution
   */
  int sample_int_from(vector<double> p);
};

#endif
